<template>
  <div id="app">
    <div class="container">
      <router-view />
    </div>
    <div class="footer">
      <cube-tab-bar
        v-model="selectedLabelDefault"
        :data="tabs"
        @click="changeHandler"
      >
      </cube-tab-bar>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selectedLabelDefault: "/",
      tabs: [
        {
          label: "首页",
          value: "/",
          icon: "cubeic-home"
        },
        {
          label: "课程",
          value: "/course",
          icon: "cubeic-like"
        },
        {
          label: "我的",
          value: "/my",
          icon: "cubeic-vip"
        },
        {
          label: "个人中心",
          value: "/profile",
          icon: "cubeic-person"
        }
      ]
    };
  },
  watch: {
    $route: {
      immediate: true,
      handler(to) {
        console.log(to);
        this.selectedLabelDefault = to.path;
      }
    }
  },
  methods: {
    changeHandler(label) {
      // if you clicked home tab, then print 'Home'
      this.$router.push(label);
    }
  }
};
</script>

<style lang="stylus">
html, body,#app
  font-family Avenir, Helvetica, Arial, sans-serif
  -webkit-font-smoothing antialiased
  -moz-osx-font-smoothing grayscale
  width 100%
  height 100%

#app
  display flex
  flex-direction column
  .container
    flex 1
    overflow scroll
  .footer
    height 44px
</style>
